<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script type="text/javascript" src="<?php echo JS_PATH?>swfupload/swf2ckeditor.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$.formValidator.initConfig({
		formid: "myform",
		autotip: true,
		onerror: function(msg, obj) {
			window.top.art.dialog({
				content: msg,
				lock: true,
				width: '200',
				height: '50'
			})
		}
	});
	$("#name").formValidator({
		onshow: "<?php echo L('input').L('contest_name')?>",
		onfocus: "<?php echo L('input').L('contest_name')?>"
	}).inputValidator({
		min: 1,
		onerror: "<?php echo L('input').L('contest_name')?>"
	});

	$("#year").formValidator({
		onshow: "<?php echo '请选择'.L('contest_year')?>",
		onfocus: "<?php echo '请选择'.L('contest_year')?>"
	}).inputValidator({
		min: 1,
		onerror: "<?php echo '请选择'.L('contest_year')?>"
	});
	$("#end_time").formValidator({ onshow: "请输入时间", onfocus: "请输入时间", oncorrect: "输入正确！" }).functionValidator({ fun: allEmpty ,onerror:"结束时间应该不小于开始时间"});
	function allEmpty(val, elem) {
    	var end_time = $('#end_time').val();
    	var begin_time = $('#begin_time').val();
    	if (end_time >= begin_time) {
    		return true;
    	}else {
    		return false;
    	}
    };


});
</script>
<div class="subnav">
	<div class="content-menu ib-a blue line-x">
	   <a href="./index.php?m=activity&c=activity&a=index" style="font-size:14px;color: #0000FF;font-weight:bolder;"><em>返回上一级</em></a>	
	</div>
</div>
<div class="pad-10">

	<form name="myform" action="?m=<?php echo ROUTE_M?>&c=<?php echo ROUTE_C?>&a=<?php echo ROUTE_A?>&id=<?=$id?>" method="post"
		id="myform" enctype="multipart/form-data">
		<div class="content pad-10" id="show_div_1" style="height: auto">
			<fieldset>
				<legend>活动信息修改</legend>
				<table width="100%" class="table_form">
					<tr>
						<td width="120"><?php echo L('contest_name')?>：</td>
						<td><input type="text" name="data[name]" id="name" class="input-text" value="<?=$name?>"  size=40 /></td>
					</tr>
					<tr>
						<td width="120">活动关键字：</td>
						<td><input type="text" name="data[keywords]"
							class="input-text" value="<?=$keywords?>"  size=40 /><span style="color: red;font-size:18px;"><strong>注意：</strong>多关键字之间用英文","隔开</span></td>
					</tr>
					<tr>
						<td width="120"><?php echo L('contest_year')?>：</td>
						<td>
							<select name="data[year]" id="year">
								<option >请选择</option>
								<?php for($i=0;$i<10;$i++) {?>
								<option value="<?php echo ($years+$i);?>" <?php if($year == ($years+$i)){ echo 'selected';} ?>><?php echo ($years+$i);?></option>
								<?php }?>
							</select>
						</td>
					</tr>
					<tr>
						<td width="120"><?php echo L('contest_time')?>：</td>

						<td>
							<?php echo form::date('data[begin_time]', substr($begin_time,0,10), 0, 0, 'true', 1)?>-<?php echo form::date('data[end_time]', substr($end_time,0,10), 0, 0, 'true', 1)?>
						</td>
					</tr>
					<tr>
						<td width="120">举办地：</td>
						<td >
							<?php echo form::select($province,$address_province,' name="data[address_province]" id="address_province" ','请选择')?>
							<?php if ($address_city) {?>
							<?php echo form::select($city,$address_city,' name="data[address_city]" id="address_city" ','请选择')?>
							<?php }else{?>
							<select name="data[address_city]" id="address_city" style='display:none'>
							
							</select>
							<?php }?>&nbsp;&nbsp;&nbsp;<span style="color: #959595;">请选择该活动的举办地！(非必选)</span>
						</td>
					</tr>
					<tr>
						<td width="120">详细地址：</td>
						<td ><input type="text" class="input-text" name="data[address_detail]" value="<?=$address_detail?>" size="40"  placeholder="请输入活动举办的详细地址..." /></td>
					</tr>
					<tr>
						<td width="120"><?php echo L('contest_type')?>：</td>
						<td>
							<?php echo form::select($types,$type,' name="data[type]"','请选择');?>&nbsp;&nbsp;&nbsp;<span style="color: #959595;">活动类型为该活动的主题、分类！(非必选)</span>
						</td>
					</tr>
					<tr>
						<td width="120">主办方：</td>
						<td>
							<?php echo form::select($organizerList,$organizerId,' name="data[organizerId]"','请选择');?>&nbsp;&nbsp;&nbsp;<span style="color: #959595;">如果为空请先在"主办方管理"中添加！(必选)</span>
						</td>
					</tr>
					<tr>
						<td width="120"><?php echo L('contest_slogan')?>：</td>
						<td><textarea rows="5" cols="80" name="data[slogan]"
									  id="slogan" placeholder="请在此输入该活动的口号..."><?php echo $slogan;?></textarea>
						</td>
					</tr>
					<tr>
						<td width="120">活动宣传图：</td>

						<td><?php echo form::images('data[image_logo]', 'image_logo', $image_logo, 'activity', '', 40)?></td>
					</tr>

					<tr>
						<td width="120"><?php echo L('contest_description')?>：</td>
						<td>
							<textarea rows="10" cols="80" name="data[description]" id="description"><?=$description?></textarea>
							<?php echo form::editor('description','full','','','',1,1)?>
						</td>
					</tr>

					<tr>
						<td width="120">报名链接：</td>
						<td><input type="text" name="data[reg_link]" class="input-text" value="<?=$reg_link?>" size="40" placeholder="请在此输入该活动的报名链接..."/>&nbsp;&nbsp;&nbsp;<span style="color: #959595;">(报名链接非必填)</span></td>
					</tr>

					<tr>
						<td width="120">报名须知：</td>
						<td>
							<textarea rows="10" cols="80" name="data[reg_introduction]" id="reg_introduction"><?=$reg_introduction?></textarea>
							<?php echo form::editor('reg_introduction','full','','','',1,1)?>
						</td>
					</tr>

					<tr>
						<td width="120">奖项介绍：</td>
						<td>
							<textarea rows="10" cols="80" name="data[award_introduction]" id="award_introduction"><?=$award_introduction?></textarea>
							<?php echo form::editor('award_introduction','full','','','',1,1)?>
						</td>
					</tr>


					</tr>
				</table>
			</fieldset>


		</div>
		<div class="bk15"></div>
		<?php if(ROUTE_M != 'information'){?>
		<input name="dosubmit" type="submit" id="dosubmit"
			value="<?php echo L('submit')?>" class="button">
		<?php }?>

	</form>

</div>
<script type="text/javascript">
	$(function(){
		$('#address_province').change(function(){
			var name = $(this).val();
			if(!name) {
				$('#address_city').html('');
				$('#address_city').hide();
			} else {
				$.ajax({
					type:"get",
					url:"?m=activity&c=activity&a=ajaxCity&pc_hash=<?php echo $_SESSION['pc_hash'];?>&name="+name,
					dataType: "json",
					success:function(data){
						var _html = '<option>请选择</option>'
						$.each(data,function(i,v){
						    _html += '<option value="'+i+'">'+v+'</option>';
						});
						$('#address_city').html(_html);
						$('#address_city').show();
					}
				})
			}
		})
	})
</script>
</body>
</html>